package thread;

public class ThreadDemo17 {
    public static void main(String[] args) throws InterruptedException {
        Object o = new Object();

        Thread t1 = new Thread(() -> {
           // 这个线程负责进行等待 
            System.out.println("t1: wait 之前");
            try {
                synchronized (o) {
                    o.wait();
                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("t1: wait 之后");
        });

        Thread t2 = new Thread(() -> {
            System.out.println("t2: notify 之前");
            synchronized (o) {
                o.notify();
            }
            System.out.println("t2: notify 之后");
        });

        t1.start();
        Thread.sleep(1000);
        t2.start();
    }
}
